package com.zb.demo.controller;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.zb.entity.City;
import com.zb.demo.service.CityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping(value = "/city")
public class CityController {
    @Autowired
    private CityService cs;

    @RequestMapping("/getAll")
    @ResponseBody
    public  Object getAll(){
        List<City> citys = cs.getAll();
        return JSONObject.toJSONString(citys, SerializerFeature.DisableCircularReferenceDetect);
    }
}
